package com.zwz.controller;

import com.zwz.dto.ExecutedPersonDTO;
import com.zwz.entity.ExecutedPerson;
import com.zwz.service.ExecutedPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/executed-persons")
public class ExecutedPersonController {

    @Autowired
    private ExecutedPersonService service;

    @PostMapping
    public ResponseEntity<?> create( ) {
        try {
            ExecutedPersonDTO dto = null;
            return ResponseEntity.status(HttpStatus.CREATED).body(dto);
        } catch (IllegalArgumentException e) {
            return ResponseEntity.badRequest().body(e.getMessage());
        }
    }

    @GetMapping("/active")
    public ResponseEntity<List<ExecutedPerson>> getActive() {
        return ResponseEntity.ok(service.getActiveExecutions());
    }
}